<!--{include header.htm}-->

<!--{hook thread_index_start.htm}-->

<div class="width">

	<!--{hook thread_index_nav_before.htm}-->
	<table id="nav" cellpadding="0" cellspacing="0" style="margin-bottom: 4px;">
		<tr>
			<td class="left"></td>
			<td class="center" style="white-space:nowrap; overflow: hidden;">
				<a class="icon icon-home" href="./"></a>
				<span class="sep"></span>
				<!--{hook common_nav_center.htm}-->
				<span><a href="?forum-index-fid-$fid-page-1.htm" id="forum_link">$forum[name]</a></span>
				<span class="sep"></span>
				<!--{hook thread_index_nav_subject_before.htm}-->
				<span><a href="?thread-index-fid-$fid-tid-$tid.htm">$thread[subject_substr]</a></span>
				<!--{hook thread_index_nav_end.htm}-->
			</td>
			<td class="center2">
				<!--{include header_user.inc.htm}-->
				<a href="?post-thread-fid-$fid-typeid1-$thread[typeid1]-typeid2-$thread[typeid2]-typeid3-$thread[typeid3]-typeid4-$thread[typeid4]-ajax-1.htm" target="_blank" onclick="return false;" id="create_thread" rel="nofollow"><span class="icon icon-post-newthread"></span> 发新帖</a>
			</td>
			<td class="right"></td>
		</tr>
	</table>
	
	<!--{hook thread_index_nav_after.htm}-->
	
	<!--{loop $postlist $post}-->
	<!--{php $u = isset($userlist[$post['uid']]) ? $userlist[$post['uid']] : array();}-->
	<!--{hook thread_index_post_loop_start.htm}-->
	<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" class="post_table">
		<tr>
			<td width="70" valign="top">
				<div>
					<a href_real="?you-index-uid-$u[uid].htm" target="_blank" href="?you-profile-uid-$u[uid]-ajax-1.htm" class="ajaxdialog_hover" ajaxdialog="{position: 5, modal: false, timeout: 1000, showtitle: false}" onclick="return false;" style="display: block" rel="nofollow" aria-label="$u[username] $post[floor]楼">
						<span class="avatar_middle border bg1" {if !empty($u[avatar_middle])}style="background-image: url($u[avatar_middle])"{/if}></span>
					</a>
				</div>
				<div style="word-break:break-all;">$u[username]</div>
				<!--{hook thread_index_userinfo.htm}-->
			</td>
			<td width="15"></td>
			<td class="post_td" valign="top">
				<span class="icon icon-left-arrow" style="position: absolute; z-index: 9; float: left; margin-left: -9px; margin-top: 10px;"></span>
				<div class="bg1 border post">
				
					<!--{hook thread_index_subject_before.htm}-->
					
					<!--{if $thread[firstpid] == $post[pid]}-->
					<h2 id="subject_$tid">
					
						<!--{if $thread[top]}--><span class="icon icon-top-$thread[top]" style="margin-right: 2px;" title="置顶主题"></span><!--{/if}-->
									
					<!--{loop $forum[types] $cateid $types}-->
						<!--{if $cateid == 1 && $thread[typeid1]}--><a href="?forum-index-fid-$fid-typeid1-$thread[typeid1].htm" target="_blank" rel="nofollow">[{$thread[typename1]}]</a><!--{/if}-->
						<!--{if $cateid == 2 && $thread[typeid2]}--><a href="?forum-index-fid-$fid-typeid2-$thread[typeid2].htm" target="_blank" rel="nofollow">[{$thread[typename2]}]</a><!--{/if}-->
						<!--{if $cateid == 3 && $thread[typeid3]}--><a href="?forum-index-fid-$fid-typeid3-$thread[typeid3].htm" target="_blank" rel="nofollow">[{$thread[typename3]}]</a><!--{/if}-->
						<!--{if $cateid == 4 && $thread[typeid4]}--><a href="?forum-index-fid-$fid-typeid4-$thread[typeid4].htm" target="_blank" rel="nofollow">[{$thread[typename4]}]</a><!--{/if}-->
					<!--{/loop}-->
					
						$thread[subject]
						
						<!--{hook thread_index_subject_end.htm}-->
					</h2>
					<!--{/if}-->
					
					<!--{hook thread_index_subject_after.htm}-->
					
					<div id="message_$post[pid]" class="message"><!--{hook thread_index_message_before.htm}-->$post[message]<!--{hook thread_index_message_end.htm}--></div>
					
					<!--{hook thread_index_message_after.htm}-->
					
					<!--{if !empty($post[attachlist])}-->
					<br />
					<div class="attachlist">
						<table width="100%" cellpadding="2" class="noborder">
							<tr>
								<td class="bold"><span class="red" style="font-size: 18px">$post[attachnum] </span>个附件</td>
								<td width="70" class="grey">售价</td>
								<td width="70" class="grey">大小</td>
								<td width="70" class="grey">下载</td>
								<td width="70" class="grey">时间</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{loop $post[attachlist] $attach}-->
							<tr>
								<td>
									<a href="?attach-dialog-fid-$fid-aid-$attach[aid]-ajax-1.htm" class="ajaxdialog" ajaxdialog="{showtitle: false, cache: true, position: 6, modal: false}" onclick="return false;" target="_blank" rel="nofollow"><img src="view/image/filetype/$attach[filetype].gif" width="16" height="16" />$attach[orgfilename]</a>
								</td>
								<td class="red">$attach[golds] 金币</td>
								<td class="grey">$attach[filesize_fmt]</td>
								<td>$attach[downloads] 次</td>
								<td class="grey">$attach[dateline_fmt]</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{/loop}-->
						</table>
					</div>
					<!--{/if}-->
					
					<!--{if $ismod && $thread[firstpid] == $post[pid] && $thread[modnum] > 0}-->
					<br />
					<div class="modlist">
						<table width="100%" cellpadding="2" class="noborder">
							<tr>
								<td width="100" class="bold"><span class="red" style="font-size: 18px">$thread[modnum] </span>条管理记录</td>
								<td width="50" class="grey">操作</td>
								<td width="50" class="grey">积分</td>
								<td width="50" class="grey">金币</td>
								<td class="grey">备注</td>
								<td width="70" class="grey">时间</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{loop $modlist $mod}-->
							<tr>
								<td>
									<a href_real="?you-index-uid-$mod[user][uid].htm" target="_blank" href="?you-profile-uid-$mod[user][uid]-ajax-1.htm" class="ajaxdialog" ajaxdialog="{position: 5, modal: false, timeout: 1000, showtitle: false}" onclick="return false;" style="display: block" rel="nofollow">
										<span class="avatar_small bg1" {if $mod[user][avatar_small]}style="background-image: url($mod[user][avatar_small])"{/if}></span>
										<span>$mod[user][username]</span>
									</a>
								</td>
								<td class="grey">$mod[action_fmt]</td>
								<td>$mod[credits_fmt]</td>
								<td class="red">$mod[golds_fmt]</td>
								<td class="grey">$mod[comment]</td>
								<td class="grey">$mod[dateline_fmt]</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{/loop}-->
						</table>
					</div>
					<!--{/if}-->
					
					<!--{if $post[rates] > 0}-->
					<br />
					<div class="ratelist">
						<table width="100%" cellpadding="2" class="noborder">
							<tr>
								<td width="100" class="bold"><span class="red" style="font-size: 18px">$post[rates] </span>条评分记录</td>
								<td width="50" class="grey">操作</td>
								<td width="50" class="grey">积分</td>
								<td width="50" class="grey">金币</td>
								<td class="grey">点评</td>
								<td width="70" class="grey">时间</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{loop $post[ratelist] $rate}-->
							<tr>
								<td>
									<a href_real="?you-index-uid-$rate[user][uid].htm" target="_blank" href="?you-profile-uid-$rate[user][uid]-ajax-1.htm" class="ajaxdialog" ajaxdialog="{position: 5, modal: false, timeout: 1000, showtitle: false}" onclick="return false;" style="display: block" rel="nofollow">
										<span class="avatar_small bg1" {if $rate[user][avatar_small]}style="background-image: url($rate[user][avatar_small])"{/if}></span>
										<span class="">$rate[user][username]</span>
									</a>
								</td>
								<td class="grey">评分</td>
								<td>$rate[credits_fmt]</td>
								<td class="red">$rate[golds_fmt]</td>
								<td class="grey">$rate[comment]</td>
								<td class="grey">$rate[dateline_fmt]</td>
							</tr>
							<tr><td colspan="6"><hr /></td></tr>
							<!--{/loop}-->
						</table>
					</div>
					<!--{/if}-->
					
					<!--{hook thread_index_attachlist_after.htm}-->
					
					<div class="grey mod" pid="$post[pid]" style="zoom: 1;">
						<div>
							<!--{if $thread[firstpid] != $post[pid]}-->
							<span style="width: 150px; float: left; text-align: left;" class="small">$post[dateline_fmt]</span>
							<!--{/if}-->
							
							<!--{if $_user[uid]}-->
							<a href="?post-post-fid-$fid-tid-$post[tid]-pid-$post[pid].htm" class="ajaxdialog" ajaxdialog="{cache: true}" onclick="return false;">引用</a>
							<!--{/if}-->
							
							<!--{if $ismod}-->	
							<a href="?mod-rate-fid-$fid-pid-$post[pid].htm" class="ajaxdialog" ajaxdialog="{position: 1, modal: false, cache: false}">评分</a>
							<!--{/if}-->
							
							<!--{if $ismod || $_user[uid] == $post[uid]}-->	
							<a href="?post-update-fid-$thread[fid]-pid-$post[pid]-ajax-1.htm" class="ajaxdialog" ajaxdialog="{modal: false, cache: false}" onclick="return false;">编辑</a>
							<a href="?post-delete-fid-$fid-pid-$post[pid].htm" class="ajaxconfirm" ajaxconfirm="{message: '确定删除吗？'}" onclick="return false;">删除</a>
							<!--{/if}-->
							
							#$post[floor]楼
						</div>
					</div>
				</div>
			</td>
		</tr>
		<!--{if $thread[firstpid] == $post[pid]}-->
		<tr>
			<td></td>
			<td></td>
			<td>
				<div class="bg2 border" style="margin-top: 1px; padding: 8px;">
					<span class="grey">发帖时间：</span><b>$post[dateline_fmt]</b> &nbsp; <span class="grey2">|</span> &nbsp; 
					<span class="grey">查看数：</span><span id="thread_views" class="bold">$thread[views]</span> &nbsp; <span class="grey2">|</span> &nbsp; 
					<span class="grey">回复数：</span><b>$thread[posts_fmt]</b>
				</div>
			</td>
		</tr>
		<!--{/if}-->
	</table>
	<!--{hook thread_index_post_loop_end.htm}-->
	<!--{/loop}-->
	
	<!--{hook thread_index_quick_post_start.htm}-->
	<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" style="margin-top: 4px;" class="post_table">
		<tr>
			<td width="70" valign="top">
				<div>
					<!--{if $_user[uid]}--><a href_real="?you-index-uid-$_user[uid].htm" target="_blank" href="?you-profile-uid-$_user[uid]-ajax-1.htm" class="ajaxdialog_hover" ajaxdialog="{position: 5, modal: false, timeout: 1000, showtitle: false}" onclick="return false;" style="display: block" rel="nofollow"><!--{/if}-->
						<span class="avatar_middle border bg1" {if !empty($_user[avatar_middle])}style="background-image: url($_user[avatar_middle])"{/if}></span>
					<!--{if $_user[uid]}--></a><!--{/if}-->
				</div>
				<div style="word-break:break-all;">$_user[username]</div>
				<div class="grey small">$_user[groupname]</div>
			</td>
			<td width="15"></td>
			<td class="post_td" valign="top">
				<span class="icon icon-left-arrow" style="position: absolute; z-index: 9; float: left; margin-left: -9px; margin-top: 10px;"></span>
				<div class="bg1 border shadow" style="padding: 8px;">
					<form action="?post-post-fid-$thread[fid]-tid-$thread[tid]-ajax-1-quickpost-1.htm" method="post" id="quick_post_form" target="_blank">
						<input type="hidden" name="FORM_HASH" value="{FORM_HASH}" />
						<!--{hook common_form_hash_after.htm}-->
						<textarea name="message" id="quick_message" style="width: 100%; height: 60px; font-size: 14px; overflow: hidden;" aria-label="快速回复内容"></textarea>
						<div style="margin-top: 4px;">
							<div style="width: 50%; float: left;">
								<input type="submit" class="button smallblue" id="quick_post_submit" value="快速回复" />
								<!--{hook thread_index_quick_post_after.htm}-->
							</div>
							<div style="width: 50%; float: left; text-align: right;">
								<!--{hook thread_index_advanced_post_after.htm}-->
							</div>
						</div>
					</form>
				</div>
			</td>
		</tr>
	</table>
	<!--{hook thread_index_quick_post_end.htm}-->
	
	<div class="box">
		<div class="page" style="text-align: center;">$pages</div>
		<!--{if $ismod}-->
		<div style="text-align: center;">
			<input type="checkbox" name="fid_tid[]" value="$thread[fid]_$thread[tid]" checked="checked" style="display: none;" />
			<input type="button" class="button smallblue" id="mod_top"  value="置顶" />
			<!--{if $forum[typecates]}-->
			<input type="button" class="button smallblue" id="mod_type"  value="主题分类" />
			<!--{/if}-->
			<input type="button" class="button smallblue" id="mod_digest"  value="精华" />
			<input type="button" class="button smallblue" id="mod_move"  value="移动" />
			<!--{hook thread_index_mod_before_delete.htm}-->
			<input type="button" class="button smallblue" id="mod_delete"  value="删除" />
			<!--{hook thread_index_mod_end.htm}-->
		</div>
		<!--{/if}-->
		<p style="text-align: center; padding: 8px;">
			<!--{if !empty($referer_other)}-->
			<input type="button" value=" 返回上一页" class="button bigblue" onclick="window.location='$referer_other'" />
			<!--{/if}-->
			<input type="button" value=" 返回【$forum[name]】" class="button bigblue" id="return_back" />
		</p>
	</div>
	
	<!--{hook thread_index_mod_after.htm}-->
	
</div>

<!--{include footer.htm}-->

<!--{if $ismod}-->
<script type="text/javascript">
// copy from forum_index.htm
// 置顶 弹出 dialog 设置为置顶
$('#mod_top').click(function() {
	var fid_tids = '';
	$.each($('#body input[name="fid_tid[]"]:checked'), function(k, v) {
		fid_tids += (fid_tids ? '__' : '') + v.value;
	});
	if(fid_tids == '') {
		alert('请选择主题！');
		return false;
	}
	var url = url_add_arg('?mod-top-fid-$fid.htm', 'fid_tids', fid_tids);
	ajaxdialog_request(url, function() {
		window.location.reload();
	});
});

// 主题分类 
$('#mod_type').click(function() {
	var fid_tids = '';
	$.each($('#body input[name="fid_tid[]"]:checked'), function(k, v) {
		fid_tids += (fid_tids ? '__' : '') + v.value;
	});
	if(fid_tids == '') {
		alert('请选择主题！');
		return false;
	}
	var url = url_add_arg('?mod-type-fid-$fid.htm', 'fid_tids', fid_tids);
	ajaxdialog_request(url, function() {
		window.location.reload();
	});
});

// 精华
$('#mod_digest').click(function() {
	var fid_tids = '';
	$.each($('#body input[name="fid_tid[]"]:checked'), function(k, v) {
		fid_tids += (fid_tids ? '__' : '') + v.value;
	});
	if(fid_tids == '') {
		alert('请选择主题！');
		return false;
	}
	var url = url_add_arg('?mod-digest-fid-$fid.htm', 'fid_tids', fid_tids);
	ajaxdialog_request(url, function() {
		window.location.reload();
	});
	return false;
});

// 删除
$('#mod_delete').click(function() {
	var fid_tids = '';
	$.each($('#body input[name="fid_tid[]"]:checked'), function(k, v) {
		fid_tids += (fid_tids ? '__' : '') + v.value;
	});
	if(fid_tids == '') {
		alert('请选择主题！');
		return false;
	}
	var url = url_add_arg('?mod-delete-fid-$fid.htm', 'fid_tids', fid_tids);
	ajaxdialog_request(url, function() {
		window.location = '?forum-index-fid-$fid.htm';
	});
});

// 移动
$('#mod_move').click(function() {
	var fid_tids = '';
	$.each($('#body input[name="fid_tid[]"]:checked'), function(k, v) {
		fid_tids += (fid_tids ? '__' : '') + v.value;
	});
	if(fid_tids == '') {
		alert('请选择主题！');
		return false;
	}
	var url = url_add_arg('?mod-move-fid-$fid.htm', 'fid_tids', fid_tids);
	ajaxdialog_request(url, function() {
		window.location = '?forum-index-fid-$fid.htm';
	});
});

</script>
<!--{/if}-->

<script type="text/javascript">

tid_add_read($tid, $_SERVER[time]);

$('#create_post').click(function() {
	if(g_uid == 0) {
		ajaxdialog_request('?user-login.htm', function() {
			$('#create_post').unbind('click');
			ajaxdialog_request($('#create_post').attr('href'));
			$('#create_post').click(function() {
				ajaxdialog_request($('#create_post').attr('href'));
			});
		});
		return false;
	} else {
		return true;
	}
});

// 点击数服务器
$.getScript('$click_server&'+Math.random(), function() {
	if(typeof xn_json == 'undefined') return;
	var json = xn_json;
	$('#thread_views').html(json['$tid']);
});

// 自动伸缩，自动提交
$('#quick_message').keyup(function(e) {
	if((e.ctrlKey && (e.which == 13 || e.which == 10)) || (e.altKey && e.which == 83)) {
		$('#quick_post_submit').trigger('click');
		return false;
	}
        
	var h = $(this)[0].scrollHeight;
	if(h <= 100) {
		return true;
	} else {
		$(this).height($(this)[0].scrollHeight);
		return true;
	}
});

// 快速回复
$('#quick_post_submit').click(function() {
	if(!$('#quick_message').val()) {
		$('#quick_message').alert('请填写内容！', {width: 150, delay: 3000}).focus();
		return false;
	}
	$('#quick_post_submit').disable();
	
	function quick_post_submit_func() {
		var postdata = $("#quick_post_form").serialize();
		$.post($('#quick_post_form').attr('action'), postdata,  function(s){
			var json = json_decode(s);
			if(error = json_error(json)) {alert(error); return false;}
			if(json.status <= 0) {
				alert(json.message);
				return false;
			} else {
				json = json.message;
				if(json.message) {
					$('#quick_message').alert(json.message, {width:250, delay: 3000}).focus();
					return false;
				}
				// hook thread_index_post_succeed_js.htm
				
				//var page = Math.max(1, intval(json.page));
				//window.location= '?thread-index-fid-$fid-tid-$tid-page-'+page+'-scrollbottom-1.htm';
				
				var post = json.post;
				// 结果直接显示在上面，不再跳转
				var s = '<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" class="post_table">\
					<tr>\
						<td width="70" valign="top">\
							<div>\
								<a href_real="?you-index-uid-$_user[uid].htm" target="_blank" href="?you-profile-uid-$_user[uid]-ajax-1.htm" class="ajaxdialog_hover" ajaxdialog="{position: 5, modal: false, timeout: 1000, showtitle: false}" onclick="return false;" style="display: block" rel="nofollow">\
									<span class="avatar_middle border bg1" {if !empty($_user[avatar_middle])}style="background-image: url($_user[avatar_middle])"{/if}></span>\
								</a>\
							</div>\
							<div style="word-break:break-all;" aria-label="'+post.username+' '+post.posts+'楼">'+post.username+'</div>\
						</td>\
						<td width="15"></td>\
						<td class="post_td" valign="top">\
							<span class="icon icon-left-arrow" style="position: absolute; z-index: 9; float: left; margin-left: -9px; margin-top: 10px;"></span>\
							<div class="bg1 border post">\
								<div id="message_'+post.pid+'" class="message">'+post.message+'</div>\
							</div>\
						</td>\
					</tr>\
				</table>';
				var jtable = $(s);
				$('table.post_table:last').before(jtable);
				//jtable.message = post.message;
				$('#quick_message').val('').focus();
				
				$('#quick_post_submit').enable();
			}
		});
	}

	if(g_uid == 0) {
		ajaxdialog_request('?user-login.htm', function() {
			quick_post_submit_func();
			return false;
		});
	} else {
		quick_post_submit_func();
		return false;
	}
});

// 滚动回复的到最底部
{if $scrollbottom}
var offset = $('#quick_message').offset();
document.documentElement.scrollTop = offset.top - 300;
$('#quick_message').focus();
{/if}

// 记录当前页码
var fid_page = $.parseJSON($.pdata(cookie_pre + 'fid_page'));
var page = fid_page ? fid_page[''+$fid] : 1;
var href = $('#forum_link').attr('href').replace(/page-1/ig, "page-"+page);
$('#forum_link').attr('href', href);
$('#return_back').click(function() {
	window.location = href;
});

// 鼠标放在头像上弹出用户信息 ajaxdialog_hover
var jajaxdialoglinks = $('a.ajaxdialog_hover');
jajaxdialoglinks.die('click').live('click', function() {window.open($(this).attr('href_real'))});
jajaxdialoglinks.die('mouseover').live('mouseover', ajaxdialog_mouseover);
jajaxdialoglinks.die('mouseout').live('mouseout', ajaxdialog_mouseout);
$('a.ajaxconfirm').die('click').live('click', ajaxdialog_confirm);

// post_td 下的图片调整大小
$(function() {
	var td_width = $('td.post_td').width() - 28;
	td_width = Math.min($('#body').width() - 170, td_width);
	$('td.post_td img').each(function() {
		if($(this).width() > td_width) {
			this.height = Math.ceil((this.height /this.width) * td_width);
			this.width = Math.ceil(td_width);
			
			this.style.cursor = 'pointer';
			this.onclick = function() {
				window.open(this.src);
			}
		}
	});
});

// 快捷键翻页
bind_document_keyup_page();
$('div.post').each(function(i) {
	var _this = this;
	$(_this).hover(
		function() {
			$(_this).find('div.mod div').show().css('opacity', 0).stop().animate({opacity:1}, 500);
		},
		function() {
			$(_this).find('div.mod div').animate({opacity:0}, 500);
		}
	)
});
</script>

<!--{hook thread_index_end.htm}-->

</body>

</html>